import { createWebHistory, createRouter,RouterOptions } from 'vue-router'
/*import useSettingStore from '@/stores/setting';*/

const routes = [
  {
    path: '/',
    redirect: '/index',
  },
  {
    path: '/home',
    name: 'home',
    component: () => import('@/views/home/index.vue'),
    children:[
      {
        path: '/index',
        name: 'index',
        component: () => import('@/views/index/index.vue'),
      }/*,
      {
        path: '/technology',
        name: 'technology',
        component: () => import('@/views/coal/technology/index'),
      },
      {
        path: '/alarm',
        name: 'alarm',
        component: () => import('@/views/coal/alarm/index'),
      },
      {
        path: '/health',
        name: 'health',
        component: () => import('@/views/coal/health/index'),
      },
      {
        path: '/sieve',
        name: 'sieve',
        component: () => import('@/views/coal/sieve/index'),
      },
      {
        path: '/monitor',
        name: 'monitor',
        component: () => import('@/views/coal/monitor/index'),
      },
      {
        path: '/statistics/:page',
        name: 'statistics',
        component: () => import('@/views/coal/statistics/index'),
        props: true,
      },
      {
        path: '/scale/:page',
        name: 'scale',
        component: () => import('@/views/coal/scale/index'),
        props: true,
      },
      {
        path: '/sieves/:page',
        name: 'sieves',
        component: () => import('@/views/coal/sieves/index'),
        props: true,
      },*/
    ]
  }
]

const router = createRouter({
  history: createWebHistory(import.meta.env.VITE_SERVER_PATH),
  routes: routes,
} as RouterOptions);

router.beforeEach((to, from, next) => {
  /*if (to.path.startsWith('/index')){
    useSettingStore().setCurrentIndex('0' ,0 )
  } else if (to.path.startsWith('/scale')){
    let param= to.path.substring(to.path.lastIndexOf('/')+1);
    useSettingStore().setCurrentIndex(param ,1 )
  } else if (to.path.startsWith('/sieves')){
    let param= to.path.substring(to.path.lastIndexOf('/')+1);
    useSettingStore().setCurrentIndex(param ,2 )
  } else if (to.path.startsWith('/statistics')){
    let param= to.path.substring(to.path.lastIndexOf('/')+1);
    useSettingStore().setCurrentIndex(param ,3 )
  } else if (to.path === '/alarm'){
    useSettingStore().setCurrentIndex('0' ,4)
  }*/
  next()
});
export default router;